#include "sampleanalysisform.h"
#include "ui_sampleanalysisform.h"

#include "Auxiliary/View/messageboxdialog.h"

SampleAnalysisForm::SampleAnalysisForm(QWidget *parent) :
    ISampleAnalysisForm(parent),
    ui(new Ui::SampleAnalysisForm)
{
    ui->setupUi(this);
    sampleAnalysis = new ISampleAnalysis(this);
    sampleAnalysis->setBLView(this);
    checked = false;
}

SampleAnalysisForm::~SampleAnalysisForm()
{
    delete ui;
}

void SampleAnalysisForm::showEvent(QShowEvent *event)
{
    sampleAnalysis->doInit();
}

void SampleAnalysisForm::closeEvent(QCloseEvent *event)
{
    MessageBoxDialog *messageBox = new MessageBoxDialog(this,\
                             QString(tr("警告：程序有一个任务正在运行中，是否结束退出操作？")));
    int result = messageBox->exec();
    if(result == QDialog::Accepted)
    {
        sampleAnalysis->doQuit();
        event->accept();
    } else {
        event->ignore();
    }
    messageBox->deleteLater();
}

void SampleAnalysisForm::hideEvent(QHideEvent *event){
}

void SampleAnalysisForm::on_Btn_newSample_clicked()
{
    sampleAnalysis->enableAnalysis(false);
    sampleInfoDialog = new SampleInfoDialog();
    int result = sampleInfoDialog->exec();
    if(result == QDialog::Accepted){
        sampleAnalysis->setSampleInfo(sampleInfoDialog->getSampleInfo());
        sampleInfoDialog->deleteLater();
    }
}

void SampleAnalysisForm::on_Btn_sampleModel_clicked()
{
    sampleAnalysis->enableAnalysis(false);
    modeDialog = new ModeDialog();
    int result = modeDialog->exec();
    if(result == QDialog::Accepted){
        sampleAnalysis->setMode(modeDialog->getAnalysisMode(),modeDialog->getBloodMode());
        modeDialog->deleteLater();
    }
}

void SampleAnalysisForm::on_Btn_sampleCheck_clicked()
{
    if(checked == false){
        checked = true;
        sampleAnalysis->setCheck(true);
        ui->Btn_sampleCheck->setText(QString(tr("取消审核")));
    } else {
        checked = false;
        sampleAnalysis->setCheck(false);
        ui->Btn_sampleCheck->setText(QString(tr("审核")));
    }
}

void SampleAnalysisForm::onDoAnalysis()
{

}

void SampleAnalysisForm::onCountCompelet()
{

}

void SampleAnalysisForm::showMessage(const QString &message){

}

